--init.lua
local mywifi = require "mywifi"
local mymqtt = require "mymqtt"
local mcunode = require "mcunode"
local dht11 = require "dht11"

MY_SSID = "DORLINK_1"
MY_PASSWORD = "dorlink1931"

--wifi连接，并设定自动重连时间
mywifi.wifiInit(4, 5, 1000)    --选择gpio4,定时器5,自动重连时间1S
--mywifi.wifiConnect(MY_SSID, MY_PASSWORD, 1000)

--成功连接并获取IP后执行mqtt
wifi.sta.eventMonReg(wifi.STA_GOTIP, function()
    mywifi.blinking()
    print("Config done, IP is "..wifi.sta.getip()) 
    mymqtt.mqttInit(0, "103.13.221.30")
    mcunode.connect("888hyg","eiot.club")
    dht11.data_Update(0, 1, 30000)
end)


tmr.alarm(1, 10000, tmr.ALARM_AUTO, function()
            collectgarbage("collect")
            print("mem")
            print(collectgarbage("count"))
            --collectgarbage("collect")
            --print(collectgarbage("count"))
        end)